{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# TDC 103: Datasets Part 1 - Small Molecules\n",
    "\n",
    "[Kexin](https://twitter.com/KexinHuang5)\n",
    "\n",
    "In this tutorial, we will walk through various small molecule datasets provided in TDC!\n",
    "\n",
    "We assume you have familiarize yourself with the installations, data loaders, and data functions. If not, please visit [TDC 101 Data Loaders](https://github.com/mims-harvard/TDC/blob/master/tutorials/TDC_101_Data_Loader.ipynb) and [TDC 102 Data Functions](https://github.com/mims-harvard/TDC/blob/master/tutorials/TDC_102_Data_Functions.ipynb) first!\n",
    "\n",
    "TDC has more than 60 datasets in the first release. In this tutorial, we highlight many of them and hopefully will give users a sense of what the TDC covers. We will start with small molecule drugs and go to biologics in the next part of the tutorial. For small molecules, we introduce the dataset in the order of discovery and development pipelines. \n",
    "\n",
    "## Small Molecule \n",
    "\n",
    "### Target Discovery\n",
    "\n",
    "The first stage of small molecule drug discovery is target discovery, that is to identify genes for the disease of interest. This is relatively underexplored for ML usage. One way to do it is by modeling it as a prediction problem for gene-disease association (GDA). TDC includes one high quality GDA data [DisGeNET](https://www.disgenet.org/), which curates from UniProt, PsyGeNET, Orphanet, the CGI, CTD (human data), ClinGen, and the Genomics England PanelApp. We also generate disease definitions for disease and amino acid sequence for gene as input features. You can access them via:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 63.9M/63.9M [00:03<00:00, 18.2MiB/s]\n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Gene_ID</th>\n",
       "      <th>Gene</th>\n",
       "      <th>Disease_ID</th>\n",
       "      <th>Disease</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>MSMLVVFLLLWGVTWGPVTEAAIFYETQPSLWAESESLLKPLANVT...</td>\n",
       "      <td>C0019209</td>\n",
       "      <td>Hepatomegaly: Abnormal enlargement of the liver.</td>\n",
       "      <td>0.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>MSMLVVFLLLWGVTWGPVTEAAIFYETQPSLWAESESLLKPLANVT...</td>\n",
       "      <td>C0036341</td>\n",
       "      <td>Schizophrenia: Schizophrenia is highly heritab...</td>\n",
       "      <td>0.3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Gene_ID                                               Gene Disease_ID  \\\n",
       "0        1  MSMLVVFLLLWGVTWGPVTEAAIFYETQPSLWAESESLLKPLANVT...   C0019209   \n",
       "1        1  MSMLVVFLLLWGVTWGPVTEAAIFYETQPSLWAESESLLKPLANVT...   C0036341   \n",
       "\n",
       "                                             Disease    Y  \n",
       "0   Hepatomegaly: Abnormal enlargement of the liver.  0.3  \n",
       "1  Schizophrenia: Schizophrenia is highly heritab...  0.3  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.multi_pred import GDA\n",
    "data = GDA(name = 'DisGeNET')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Gene_ID is the GenBank GeneID and the Disease_ID is the Concept ID from MedGen. We can see the association distribution by:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEWCAYAAAB/tMx4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXhU5dn48e89ySSTjQQSNgkYNhGrgIKK2FqK9BURtK24VVG6WbV1aaXta9WKr7jUttal1Z9oLS6oULVVFKyKpm5ACbLLKgYIiyEBsm+TeX5/nJOQhEkySWZOZrk/15UrM3OW+54zM/c885xzniPGGJRSSkUeV3cnoJRSqnO0gCulVITSAq6UUhFKC7hSSkUoLeBKKRWhtIArpVSE0gLuIBHJFZEfO72svfw3RGRrZ5f3s76lInKNfXuWiHwcxHVfKSLvBGt9HYh7tohsF5FyEflOJ9fx/0TkzmDnppQ/WsA7QUTyRWRyd+fRQETmiEidiJTZf9tE5C8i0r9hHmPMR8aYEQGu64X25jPGnG+MeTYIueeIiBGR+CbrXmCM+Z+urrsT/g/4izEm1Rjzr5YT7de9yt7GR0TkUxG5TkQaP0fGmOuMMfcEEkxELheRlSJSISKF9u0bREQCWHaivd3+2uLxj0Vkln17lojU219ITf+Oa3HfZz+vhvtX+ok3X0Rqm7zHNorI/SKSHshztdfhyOcm3D6foaQFPHosNMakAb2A7wL9gNVNi3gwiCVa3zfHA5vamWe6vZ2PBx4AfgP8raOBRORW4BHgD1ivVV/gOuBsICHA1VQAV4tIThvzLLe/kJr+7Wt6H9htP6+Gxxa0sq4H7efeG/gBMB74RERSAsxXBVm0fhC7hYj0FJE3ReSgiBy2b2e3mG2oiPxXREpE5HUR6dVk+fF2q+6IiKwTkYkdzcEYU2eM2QRcBhwEbrXXPVFECprE+o2I7LVbU1tF5FwRmQL8FrjMbomts+fNFZF7ReQToBIY4qdLR0TkMft5bRG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n9RW/bF/Dr7aRoLOCBnuL/V2PMUOA3wB0hz8rSZm4i4gL+DNzqUD6Nof081nKbLQZyjDGjgPeAZ0OelSWQ3OKxulEmYrV0nxaRUF9ENKD3me1y4BVjTMevhN05geR2BTDfGJON1T3wvP3+6+68ZgPfFJE1wDeBvYD3mKWc15HX2zHRWMA7eor/y8B3QprRUe3llgacDOSKSD5WX9sbDuzIbHebGWOKjTENg5w/BYwNcU4B52bP87oxps4Y8yXWgGnDwyCvBpfjXPcJBJbbj4BFAMaY5YAHa9Cmbs3LGLPPGPM9Y8ypwO32YyUhzisQ4Tl0SHd3wodgZ0Q8sBPrJ2vDjpKvtZhneJPb04G8cMmtxfy5OLMTM5Bt1r/J7e8CK8JlmwFTgGft21lYP3Uzuzsve74RQD72SXNhtM2WArPs2yOxilFIcwwwryzAZd++F/g/B7dbDq3vxLyA5jsx/+tUXm3m3N0JhOiFmIp1sYkvgNvtx/4PuNC+/QiwCViLtaOk1SLqdG4t5nWkgAe4ze63t9k6e5udGC7bzP5QPQR8DmwALg+HvOz7c4AHnNpWHdhmJwGf2K/nWuB/wiSvGcB2e56ngUSH8noJ2A/UYbW2fwRcB1zX5D32VzvvDU59Ltv701PplVIqQkVjH7hSSsUELeBKKRWhtIArpVSE0gKulFIRSgu4UkpFKC3gKmbZI8x9LCLnN3nsUhF5uzvzUipQehihimkicjLWCHinYo2WtxaYYoz5olsTUyoAWsBVzBORB4EKrJEpy4wx93RzSkoFRAu4inkikgJ8BtRinWFX084iSoWFTl+VXqloYYypEJGFQLkWbxVJdCemUhaf/adUxNACrpRSEUoLuFJKRSjdiamUUhFKW+BKKRWhtIArpVSE0gKulFIRSgu4UkpFKC3gSikVobSAK6VUhNICrpRSEer/A6lUjN7wrfXcAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.label_distribution()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, you can build ML models to predict this association. Also, note that another way to phrase it is as a missing link prediction problem in Gene-Disease Association Network, where you can apply recent Graph ML to do interesting predictions. You can obtain the network object of edge list/DGL/PyG format using TDC data functions. For example, we want to include all associations above 0.35 as edges. Then, to obtain DGL object, type:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "The dataset label consists of affinity scores. Binarization using threshold 0.35 is conducted to construct the positive edges in the network. Adjust the threshold by to_graph(threshold = X)\n",
      "Using backend: pytorch\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "DGLGraph(num_nodes=9432, num_edges=15484,\n",
       "         ndata_schemes={}\n",
       "         edata_schemes={})"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graph = data.to_graph(threshold = 0.35, format = 'dgl', split = True, frac = [0.7, 0.1, 0.2], seed = 'benchmark', order = 'ascending')\n",
    "graph['dgl_graph']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In additiont to predicting GDA, there are also research doing target fishing using drug-target interaction dataset.\n",
    "\n",
    "### Activity\n",
    "\n",
    "After we found the target, we want to screen a large set of compounds to identify the ones who have high binding affinity or activity to the disease target. The binding affinity is generated via high-throughput screening. There are huge amounts of wet lab data available out there for various disease targets. Instead of including all of them, TDC aims to include assays for disease of current interest. For example, we include a SARS-CoV2 in vitro data from Touret et al.:   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 101k/101k [00:00<00:00, 626kiB/s] \n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Drug_ID</th>\n",
       "      <th>Drug</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>CCOC1=CC2=C(C=C1)N=C(S2)S(=O)(=O)N</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>C[C@]12CC[C@H]3[C@H]([C@@H]1CC[C@]2(C)O)CC[C@@...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Drug_ID                                               Drug  Y\n",
       "0        0                 CCOC1=CC2=C(C=C1)N=C(S2)S(=O)(=O)N  1\n",
       "1        1  C[C@]12CC[C@H]3[C@H]([C@@H]1CC[C@]2(C)O)CC[C@@...  1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.single_pred import HTS\n",
    "data = HTS(name = 'SARSCoV2_Vitro_Touret')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For HTS, we hope to be a community driven effort, where domain people can point out disease of interests and the corresponding assay data and then we could quickly add it to TDC. This would make TDC reflect the state-of-the-art landscape of diseases targets and allow machine learning scientists to build models to aid the development of that disease. If you have any idea, please don't hesitate to [contact us](mailto:kexinhuang@hsph.harvard.edu). \n",
    "\n",
    "While HTS is restricted to one target protein, drug-target interaction (DTI) dataset combines many assays. One huge advantage of it is that a ML model learned on HTS dataset can only do prediction on one protein whereas a ML model learned on DTI dataset learns both disease proteins and drugs chemicals and thus can generalize to unseen drugs/targets. TDC includes several DTI datasets, including the largest BindingDB dataset. Note that BindingDB is the collection of many assays. Since different assays use different units, TDC separates them as separate datasets. Specifically, it has four datasets with Kd, IC50, EC50, Ki as the units. We load Kd here as an example for the sake of tutorial example (although IC50 has much larger number of data points, ~1Million):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 54.4M/54.4M [00:03<00:00, 16.5MiB/s]\n",
      "Loading...\n",
      "--- Dataset Statistics ---\n",
      "10665 unique drugs.\n",
      "1413 unique targets.\n",
      "66444 drug-target pairs.\n",
      "--------------------------\n",
      "Done!\n"
     ]
    }
   ],
   "source": [
    "from tdc.multi_pred import DTI\n",
    "data = DTI(name = 'BindingDB_Kd', print_stats = True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Another way to find compound that has affinity to disease target is through molecule generation. Molecule generation model is roughly defined as a generative model that generates new molecule structure that achieves some desirable properties such as high binding affinity to a target. There are mainly three diagrams: 1) goal-oriented learning where the ML model generates new molecule individually that achieves high score through oracles; 2) distribution learning aims to learn the distribution of the training set and generates molecule from this learnt distribution; 3) pair molecule generation formulates generation as a translation problem where it is to translate from drug X to Y where X and Y are similar but X has low score and Y has high score. \n",
    "\n",
    "The datasets for 1 and 2 are any compound library. We provide several compound libraries and oracles in TDC. For compound library, we have MOSES, ChEMBL and ZINC. For example, to load MOSES:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 75.3M/75.3M [00:04<00:00, 18.1MiB/s]\n",
      "Loading...\n",
      "There are 1936962 molecules \n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>smiles</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>CCCS(=O)c1ccc2[nH]c(=NC(=O)OC)[nH]c2c1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>CC(C)(C)C(=O)C(Oc1ccc(Cl)cc1)n1ccnc1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   smiles\n",
       "0  CCCS(=O)c1ccc2[nH]c(=NC(=O)OC)[nH]c2c1\n",
       "1    CC(C)(C)C(=O)C(Oc1ccc(Cl)cc1)n1ccnc1"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.generation import MolGen\n",
    "data = MolGen(name = 'MOSES', print_stats = True)\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using the same library, different task for goal-oriented and distribution training is defined by different oracles. For example, for goal-oriented, we have an oracle measures the affinity to target DRD2, another task has oracle that measures the affinity to target GSK3B and so on. We use the example of GSK3B here:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 27.8M/27.8M [00:01<00:00, 16.2MiB/s]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[0.05, 0.0]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc import Oracle\n",
    "oracle = Oracle(name = 'GSK3B')\n",
    "oracle(['CCOC1=CC(=C(C=C1C=CC(=O)O)Br)OCC', \n",
    "        'CC(=O)OC1=CC=CC=C1C(=O)O'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For all the goal-oriented and generation oracles, please checkout the [TDC oracle webpage](https://zitniklab.hms.harvard.edu/TDC/functions/oracles/). \n",
    "\n",
    "We also provide three datasets for pair molecule generation DRD2, QED and LogP. For example, to load DRD2 dataset, you can type:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 3.14M/3.14M [00:00<00:00, 3.75MiB/s]\n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>X</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Cn1c(CN2CCN(c3ncccn3)CC2)cc(=O)n(C)c1=O</td>\n",
       "      <td>CC1(C)CC(=O)N(CCCCN2CCN(c3ncccn3)CC2)C(=O)C1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>C[C@@H](Sc1ncc(-c2ccccc2)n1C)C(=O)N[C@@H]1CCCc...</td>\n",
       "      <td>CC(C(=O)NC1CCCc2ccccc21)N1CCN(c2ccc(F)cc2)CC1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                   X  \\\n",
       "0            Cn1c(CN2CCN(c3ncccn3)CC2)cc(=O)n(C)c1=O   \n",
       "1  C[C@@H](Sc1ncc(-c2ccccc2)n1C)C(=O)N[C@@H]1CCCc...   \n",
       "\n",
       "                                               Y  \n",
       "0   CC1(C)CC(=O)N(CCCCN2CCN(c3ncccn3)CC2)C(=O)C1  \n",
       "1  CC(C(=O)NC1CCCc2ccccc21)N1CCN(c2ccc(F)cc2)CC1  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.generation import PairMolGen\n",
    "data = PairMolGen(name = 'DRD2')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The previous dataset assumes a one-drug-fits-all-patients diagram whereas in reality different patient has different response to the same drug, especially in the case of oncology where patient genomics is a deciding factor for a drug's effectiveness. This is also coined as precision oncology. In TDC, we include Genomics in Drug Sensitivity in Cancer (GDSC) dataset which measures the drug response in various cancer cell lines. In the dataset, we also include SMILES string for the drug and the gene expression for cell lines. There are two versions of GDSC where GDSC2 uses improved experimental procedures. To access the data, for example, type:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 117M/117M [00:06<00:00, 18.8MiB/s] \n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Drug_ID</th>\n",
       "      <th>Drug</th>\n",
       "      <th>Cell Line_ID</th>\n",
       "      <th>Cell Line</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Camptothecin</td>\n",
       "      <td>CC[C@@]1(C2=C(COC1=O)C(=O)N3CC4=CC5=CC=CC=C5N=...</td>\n",
       "      <td>HCC1954</td>\n",
       "      <td>[8.54820830373167, 2.5996072676336297, 10.3759...</td>\n",
       "      <td>-0.251083</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Camptothecin</td>\n",
       "      <td>CC[C@@]1(C2=C(COC1=O)C(=O)N3CC4=CC5=CC=CC=C5N=...</td>\n",
       "      <td>HCC1143</td>\n",
       "      <td>[7.58193774904993, 2.81430257671695, 10.363326...</td>\n",
       "      <td>1.343315</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Drug_ID                                               Drug  \\\n",
       "0  Camptothecin  CC[C@@]1(C2=C(COC1=O)C(=O)N3CC4=CC5=CC=CC=C5N=...   \n",
       "1  Camptothecin  CC[C@@]1(C2=C(COC1=O)C(=O)N3CC4=CC5=CC=CC=C5N=...   \n",
       "\n",
       "  Cell Line_ID                                          Cell Line         Y  \n",
       "0      HCC1954  [8.54820830373167, 2.5996072676336297, 10.3759... -0.251083  \n",
       "1      HCC1143  [7.58193774904993, 2.81430257671695, 10.363326...  1.343315  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.multi_pred import DrugRes\n",
    "data = DrugRes(name = 'GDSC2')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Another important trend is drug combinations. Drug combinations can achieve synergistic effect and improves treatment outcome. In the first version of TDC, we include one drug synergy dataset OncoPolyPharmacology, where it includes experimental results of drug pair combination response to various cancer cell lines. You can obtain it via: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 1.62G/1.62G [01:29<00:00, 18.1MiB/s] \n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Drug1_ID</th>\n",
       "      <th>Drug2_ID</th>\n",
       "      <th>Cell_Line_ID</th>\n",
       "      <th>Y</th>\n",
       "      <th>Cell_Line</th>\n",
       "      <th>Drug1</th>\n",
       "      <th>Drug2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5-FU</td>\n",
       "      <td>ABT-888</td>\n",
       "      <td>A2058</td>\n",
       "      <td>7.693530</td>\n",
       "      <td>[5.291146039856301, 5.040386719464342, 5.29114...</td>\n",
       "      <td>O=c1[nH]cc(F)c(=O)[nH]1</td>\n",
       "      <td>CC1(c2nc3c(C(N)=O)cccc3[nH]2)CCCN1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5-FU</td>\n",
       "      <td>ABT-888</td>\n",
       "      <td>A2780</td>\n",
       "      <td>7.778053</td>\n",
       "      <td>[5.291146039856301, 5.040386719464342, 5.29114...</td>\n",
       "      <td>O=c1[nH]cc(F)c(=O)[nH]1</td>\n",
       "      <td>CC1(c2nc3c(C(N)=O)cccc3[nH]2)CCCN1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Drug1_ID Drug2_ID Cell_Line_ID         Y  \\\n",
       "0     5-FU  ABT-888        A2058  7.693530   \n",
       "1     5-FU  ABT-888        A2780  7.778053   \n",
       "\n",
       "                                           Cell_Line                    Drug1  \\\n",
       "0  [5.291146039856301, 5.040386719464342, 5.29114...  O=c1[nH]cc(F)c(=O)[nH]1   \n",
       "1  [5.291146039856301, 5.040386719464342, 5.29114...  O=c1[nH]cc(F)c(=O)[nH]1   \n",
       "\n",
       "                                Drug2  \n",
       "0  CC1(c2nc3c(C(N)=O)cccc3[nH]2)CCCN1  \n",
       "1  CC1(c2nc3c(C(N)=O)cccc3[nH]2)CCCN1  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.multi_pred import DrugSyn\n",
    "data = DrugSyn(name = 'OncoPolyPharmacology')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Efficacy and Safety\n",
    "\n",
    "After a compound is found to have high affinity to the target disease, it needs to have numerous drug-likeliness properties for it to be delivered safely and efficaciously to the human body. That is good ADME (Absorption, Distribution, Metabolism, and Execretion) properties. ADME datasets are scattered around the internet, there are several great resource on ADME prediction web services, but there is a limited set of organized data for machine learning scientists to build models upon and improve the model performances. In TDC first release, we collect 21 ADME datasets from various public sources such as eDrug3D, AqSolDB, Molecule Net, and various papers supplementary. You can find all the datasets by typing:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['lipophilicity_astrazeneca',\n",
       " 'solubility_aqsoldb',\n",
       " 'hydrationfreeenergy_freesolv',\n",
       " 'caco2_wang',\n",
       " 'hia_hou',\n",
       " 'pgp_broccatelli',\n",
       " 'f20_edrug3d',\n",
       " 'f30_edrug3d',\n",
       " 'bioavailability_ma',\n",
       " 'vd_edrug3d',\n",
       " 'cyp2c19_veith',\n",
       " 'cyp2d6_veith',\n",
       " 'cyp3a4_veith',\n",
       " 'cyp1a2_veith',\n",
       " 'cyp2c9_veith',\n",
       " 'halflife_edrug3d',\n",
       " 'clearance_edrug3d',\n",
       " 'bbb_adenot',\n",
       " 'bbb_martins',\n",
       " 'ppbr_ma',\n",
       " 'ppbr_edrug3d']"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc import utils\n",
    "utils.retrieve_dataset_names('ADME')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As always, you can load and process the data through TDC data loaders. For example, to load the P-glycoprotein Inhibition dataset, type:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 129k/129k [00:00<00:00, 751kiB/s] \n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Drug_ID</th>\n",
       "      <th>Drug</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3,5,7-Trihydroxy-3',4',5'-trimethoxyflavone</td>\n",
       "      <td>Oc1cc(O)c2c(=O)c(O)c(oc2c1)c1cc(OC)c(OC)c(OC)c1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>3,6,3',4'-Tetramethoxyflavone</td>\n",
       "      <td>COc1cc2c(oc(c(OC)c2=O)c2cc(OC)c(OC)cc2)cc1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                       Drug_ID  \\\n",
       "0  3,5,7-Trihydroxy-3',4',5'-trimethoxyflavone   \n",
       "1                3,6,3',4'-Tetramethoxyflavone   \n",
       "\n",
       "                                              Drug  Y  \n",
       "0  Oc1cc(O)c2c(=O)c(O)c(oc2c1)c1cc(OC)c(OC)c(OC)c1  1  \n",
       "1       COc1cc2c(oc(c(OC)c2=O)c2cc(OC)c(OC)cc2)cc1  1  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.single_pred import ADME\n",
    "data = ADME(name = 'Pgp_Broccatelli')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to ADME, the drug has to have low toxicity. We put all of them under the task `Tox`, where we collect Tox21, ToxCast, ClinTox. For Tox21 and ToxCast, they are wet lab results for various toxicity assays. So you can retrieve any of the assay outcome by specifying the assay name. You can find all the assay name and retrieve the corresponding data via:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['NR-AR', 'NR-AR-LBD', 'NR-AhR']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.utils import retrieve_label_name_list\n",
    "label_list = retrieve_label_name_list('Tox21')\n",
    "label_list[:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 712k/712k [00:00<00:00, 1.75MiB/s]\n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Drug_ID</th>\n",
       "      <th>Drug</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>TOX3021</td>\n",
       "      <td>CCOc1ccc2nc(S(N)(=O)=O)sc2c1</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>TOX3020</td>\n",
       "      <td>CCN1C(=O)NC(c2ccccc2)C1=O</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Drug_ID                          Drug    Y\n",
       "0  TOX3021  CCOc1ccc2nc(S(N)(=O)=O)sc2c1  0.0\n",
       "1  TOX3020     CCN1C(=O)NC(c2ccccc2)C1=O  0.0"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.single_pred import Tox\n",
    "data = Tox(name = 'Tox21', label_name = label_list[0])\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Similar to using molecule generation oracle for high binding affinity to a target, we can use generation for property improvement. Just simply switching an oracle. For example, for a drug to be synthesizable, we can use the Synthetic Accessibility oracle:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 9.05M/9.05M [00:00<00:00, 10.0MiB/s]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[2.206330025677943, 1.580039750008826]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc import Oracle\n",
    "oracle = Oracle(name = 'SA')\n",
    "oracle(['CCOC1=CC(=C(C=C1C=CC(=O)O)Br)OCC', \n",
    "        'CC(=O)OC1=CC=CC=C1C(=O)O'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to individual efficacy and safety, a drug can clash with each other to have adverse effects, i.e. drug-drug interactions (DDIs). This becomes more and more important as more people are taking combination of drugs for various diseases and it is impossible to screen the combination of all of them in wet lab, especially for higher-order combinations. In TDC, we include the DrugBank and TWOSIDES datasets for DDI. For DrugBank, instead of the standard binary dataset, we use the full multi-typed DrugBank where there are more than 80 DDI types:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 44.4M/44.4M [00:02<00:00, 15.6MiB/s]\n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Drug1_ID</th>\n",
       "      <th>Drug1</th>\n",
       "      <th>Drug2_ID</th>\n",
       "      <th>Drug2</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>DB04571</td>\n",
       "      <td>CC1=CC2=CC3=C(OC(=O)C=C3C)C(C)=C2O1</td>\n",
       "      <td>DB00460</td>\n",
       "      <td>COC(=O)CCC1=C2NC(\\C=C3/N=C(/C=C4\\N\\C(=C/C5=N/C...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>DB00855</td>\n",
       "      <td>NCC(=O)CCC(O)=O</td>\n",
       "      <td>DB00460</td>\n",
       "      <td>COC(=O)CCC1=C2NC(\\C=C3/N=C(/C=C4\\N\\C(=C/C5=N/C...</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Drug1_ID                                Drug1 Drug2_ID  \\\n",
       "0  DB04571  CC1=CC2=CC3=C(OC(=O)C=C3C)C(C)=C2O1  DB00460   \n",
       "1  DB00855                      NCC(=O)CCC(O)=O  DB00460   \n",
       "\n",
       "                                               Drug2  Y  \n",
       "0  COC(=O)CCC1=C2NC(\\C=C3/N=C(/C=C4\\N\\C(=C/C5=N/C...  1  \n",
       "1  COC(=O)CCC1=C2NC(\\C=C3/N=C(/C=C4\\N\\C(=C/C5=N/C...  1  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.multi_pred import DDI\n",
    "data = DDI(name = 'DrugBank')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can get what the label represents by typing:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "#Drug1 may increase the photosensitizing activities of #Drug2.\n",
      "#Drug1 may increase the anticholinergic activities of #Drug2.\n",
      "The bioavailability of #Drug2 can be decreased when combined with #Drug1.\n"
     ]
    }
   ],
   "source": [
    "from tdc.utils import get_label_map\n",
    "label_map = get_label_map(name = 'DrugBank', task = 'DDI')\n",
    "print(label_map[1])\n",
    "print(label_map[2])\n",
    "print(label_map[3])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "After finding a safe and efficacious compound, usually a compound lead goes to pre-clinical study and then clinical trials. TDC currently does not support any tasks in these stages, but we are actively looking for including them (e.g. one task coming in a few months is clinical trial outcome prediction). **If you have any dataset related to this, please [contact us](mailto:kexinhuang@hsph.harvard.edu).**\n",
    "\n",
    "### Manufacturing\n",
    "\n",
    "After discovering a potential drug candidate, a big portion of drug development is manufacturing, that is how to make the drug candidate from basis reactants and catalysts. \n",
    "\n",
    "TDC currently includes four tasks in this stage. The first is reaction prediction, where one wants to predict the reaction outcome given the reactants. TDC parses out the full USPTO dataset and obtains 1,939,253 reactions. You can load the data via:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 795M/795M [00:44<00:00, 17.8MiB/s] \n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>input</th>\n",
       "      <th>output</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[C:1]([C:5]1[CH:10]=[CH:9][C:8]([OH:11])=[CH:7...</td>\n",
       "      <td>[C:1]([CH:5]1[CH2:6][CH2:7][CH:8]([OH:11])[CH2...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[Cl-].[Al+3].[Cl-].[Cl-].[Cl:5][CH2:6][CH2:7][...</td>\n",
       "      <td>[Cl:5][CH2:6][CH2:7][CH2:8][C:9]([C:15]1[CH:16...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                               input  \\\n",
       "0  [C:1]([C:5]1[CH:10]=[CH:9][C:8]([OH:11])=[CH:7...   \n",
       "1  [Cl-].[Al+3].[Cl-].[Cl-].[Cl:5][CH2:6][CH2:7][...   \n",
       "\n",
       "                                              output  \n",
       "0  [C:1]([CH:5]1[CH2:6][CH2:7][CH:8]([OH:11])[CH2...  \n",
       "1  [Cl:5][CH2:6][CH2:7][CH2:8][C:9]([C:15]1[CH:16...  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.generation import Reaction\n",
    "data = Reaction(name = 'USPTO')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to the forward synthesis, a realistic scenario is one has the product and wants to know what is the reactants that can generate this product. This is also called retrosynthesis. Using the same USPTO dataset above and flip the input and output, we can get the retrosynthesis dataset. A popular smaller dataset is USPTO-50K that is widely used in ML community. USPTO-50K is a subset of USPTO. TDC also includes it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 5.22M/5.22M [00:00<00:00, 5.57MiB/s]\n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>input</th>\n",
       "      <th>output</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>COC(=O)CCC(=O)c1ccc(OC2CCCCO2)cc1O</td>\n",
       "      <td>C1=COCCC1.COC(=O)CCC(=O)c1ccc(O)cc1O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>COC(=O)c1cccc(-c2nc3cccnc3[nH]2)c1</td>\n",
       "      <td>COC(=O)c1cccc(C(=O)O)c1.Nc1cccnc1N</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                input                                output\n",
       "0  COC(=O)CCC(=O)c1ccc(OC2CCCCO2)cc1O  C1=COCCC1.COC(=O)CCC(=O)c1ccc(O)cc1O\n",
       "1  COC(=O)c1cccc(-c2nc3cccnc3[nH]2)c1    COC(=O)c1cccc(C(=O)O)c1.Nc1cccnc1N"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.generation import RetroSyn\n",
    "data = RetroSyn(name = 'USPTO-50K')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to reaction predictions, it is also important to predict the reaction condition. One condition is the catalyst. Given the reactants and products, we want to predict the catalyst type. TDC again mines through the USPTO dataset and obtains 1,257,015 reactions with 888 common catalyst types."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 565M/565M [00:35<00:00, 16.1MiB/s] \n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Reactant_ID</th>\n",
       "      <th>Reactant</th>\n",
       "      <th>Product_ID</th>\n",
       "      <th>Product</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>reactant_1</td>\n",
       "      <td>[C:1]([C:5]1[CH:10]=[CH:9][C:8]([OH:11])=[CH:7...</td>\n",
       "      <td>product_1</td>\n",
       "      <td>[C:1]([CH:5]1[CH2:6][CH2:7][CH:8]([OH:11])[CH2...</td>\n",
       "      <td>181</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>reactant_2</td>\n",
       "      <td>[Cl-].[Al+3].[Cl-].[Cl-].[Cl:5][CH2:6][CH2:7][...</td>\n",
       "      <td>product_2</td>\n",
       "      <td>[Cl:5][CH2:6][CH2:7][CH2:8][C:9]([C:15]1[CH:16...</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Reactant_ID                                           Reactant Product_ID  \\\n",
       "0  reactant_1  [C:1]([C:5]1[CH:10]=[CH:9][C:8]([OH:11])=[CH:7...  product_1   \n",
       "1  reactant_2  [Cl-].[Al+3].[Cl-].[Cl-].[Cl:5][CH2:6][CH2:7][...  product_2   \n",
       "\n",
       "                                             Product    Y  \n",
       "0  [C:1]([CH:5]1[CH2:6][CH2:7][CH:8]([OH:11])[CH2...  181  \n",
       "1  [Cl:5][CH2:6][CH2:7][CH2:8][C:9]([C:15]1[CH:16...    2  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.multi_pred import Catalyst\n",
    "data = Catalyst(name = 'USPTO_Catalyst')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As in the dataset, we make it machine learning ready, which means the labels are integers values. You can also see what each label index corresponds to by:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C1COCC1\n",
      "C(Cl)Cl\n",
      "CN(C=O)C\n"
     ]
    }
   ],
   "source": [
    "from tdc.utils import get_label_map\n",
    "label_map = get_label_map(name = 'USPTO_Catalyst', task = 'Catalyst')\n",
    "print(label_map[1])\n",
    "print(label_map[2])\n",
    "print(label_map[3])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Another important factor of drug manufacturing is yields. TDC includes two Yields dataset. One is what we mine through USPTO. But as there is recent research from Schwaller et al. argues that USPTO is a bit too noisy. We thus also includes another dataset used in Schwaller et al., Buchwald-Hartwig. You can obtain it via: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading...\n",
      "100%|██████████| 15.0M/15.0M [00:01<00:00, 11.7MiB/s]\n",
      "Loading...\n",
      "Done!\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Reaction_ID</th>\n",
       "      <th>Reaction</th>\n",
       "      <th>Y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>reactions_1</td>\n",
       "      <td>{'reactant': 'FC(F)(F)c1ccc(Cl)cc1.Cc1ccc(N)cc...</td>\n",
       "      <td>0.106578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>reactions_2</td>\n",
       "      <td>{'reactant': 'FC(F)(F)c1ccc(Br)cc1.Cc1ccc(N)cc...</td>\n",
       "      <td>0.147479</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Reaction_ID                                           Reaction         Y\n",
       "0  reactions_1  {'reactant': 'FC(F)(F)c1ccc(Cl)cc1.Cc1ccc(N)cc...  0.106578\n",
       "1  reactions_2  {'reactant': 'FC(F)(F)c1ccc(Br)cc1.Cc1ccc(N)cc...  0.147479"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc.single_pred import Yields\n",
    "data = Yields(name = 'Buchwald-Hartwig')\n",
    "data.get_data().head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "That's a long tutorial! Hope you are now pretty familiar with what TDC covers for small molecule drugs. In the next tutorial, we will talk about machine learning datasets for biologics! Also attached here for the next few tutorials:\n",
    "\n",
    "* [TDC 103 Part 2: Datasets - Biologics](https://github.com/mims-harvard/TDC/blob/master/tutorials/TDC_103_Datasets_Biologics.ipynb)\n",
    "\n",
    "* [TDC 104 ML Model Examples with DeepPurpose](https://github.com/mims-harvard/TDC/blob/master/tutorials/TDC_104_ML_Model_DeepPurpose.ipynb)\n",
    "\n",
    "* [TDC 105 Molecular Oracles](https://github.com/mims-harvard/TDC/blob/master/tutorials/TDC_105_Oracles.ipynb)\n",
    "\n",
    "See you there!"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:DeepPurpose]",
   "language": "python",
   "name": "conda-env-DeepPurpose-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
